import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/scss/reset.scss'
import './plugins/element.js'
import http from './api/config'
import './mock'
import { Message } from 'element-ui'
Vue.component(Message.name, Message)
Vue.prototype.$message = Message
Vue.config.productionTip = false
Vue.prototype.$http = http

router.beforeEach((to, from, next) => {
  store.commit('getToken')
  let token = store.state.user.token
  if (!token && to.name != 'login') {
    next({ name: 'login' })
  } else {
    next()
  }
})
new Vue({
  router,
  store,
  render: h => h(App),
  created() {
    store.commit('addMenu', router)
  },
}).$mount('#app')
